package com.scilvet.reportcomposer.report;

import com.scilvet.reportcomposer.node.Node;

public class ReportLine extends Line {

	private String description;
	private Node expression;
	
	protected ReportLine(Integer lineNumber, String description, Node expression) {
		super(lineNumber);
		
		if (description == null || expression == null) {
			throw new IllegalArgumentException("Cannot create new rule from null parameters");
		}
		
		this.lineNumber = lineNumber;
		this.description = description;
		this.expression = expression;
	}
	
	public String getDescription() {
		return description;
	}
	
	public Node getExpression() {
		return expression;
	}
	
	@Override
	public String toString() {
		return "line(" + lineNumber + ", " + description + ") = " + expression.toString() + ";";
	}
	
	public String printValues() {
		return "line(" + lineNumber + ", " + description + ") = " + expression.printValues();
	}

	@Override
	public String[] lineArray() {
		
		String[] outputArray = new String[3];
		outputArray[0] = lineNumber.toString();
		outputArray[1] = description;
		outputArray[2] = expression.getValue().toString();
		
		return outputArray;
	}
}
